#include<stdlib.h>
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<sys/ipc.h>
#include<sys/shm.h>

int main(int argc,char **argv){

   
   int shmid = 0;
   shmid = shmget((size_t)0x1000,1024,0640|IPC_CREAT);
   if(shmid == -1){
      perror("shmget");
      exit(1);
   }
   char *ptr = (char *)shmat(shmid,0,0);

   sprintf(ptr,"this is my pid = %d",getpid());
   printf(" %s \n",ptr);
   sleep(5);
   shmdt(ptr);
   shmctl(shmid,IPC_RMID,0);
   






   return 0;
}